﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;

namespace newTurtle8
{
    class DataGridTabPage : TabPage
    {
        SqlCommand selectCmd;
        private DataGridView dgv = new DataGridView();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="occupation">the army occupation of the warrior</param>
        /// <param name="spName">stored procedure to bind</param>
        /// <param name="text">he</param>
        public DataGridTabPage(string occupation, string spName, string hebDescription)
        {
            this.Name = occupation;
            this.Text = hebDescription;
            selectCmd = SqlManager.SqlCommandFactory(spName);

            dgv.AllowUserToAddRows = false;
            dgv.ReadOnly = true;
            dgv.Dock = DockStyle.Fill;
            dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            this.Controls.Add(dgv);

            refresh();
        }
        public void refresh()
        {
            DataTable dt = SqlManager.selectSqlQueryDataTable(selectCmd);
            dgv.DataSource = dt;
            Translator.setTableColumnHeadersHebrew(dt.Columns);
        }

    }
}
